<template>
	<view>
		<cu-custom bgColor="bg-blue">
			<block slot="content">个人中心</block>
		</cu-custom>
		<view class="one_box flex bg-blue">
			<view class="one_box flex" @click="skip_save(school_id)">
				<view class="img_box">
					<image :src="logo" class="img_school" v-if="logo"></image>
					<view v-if="!logo" class="nologo_img" style="background-color: #007AFF;">{{school_name[0]}}</view>
				</view>
				<view class="text_box" >
					<view class="schootext_box">{{school_name}}</view>
					<view class="id_box">ID:{{school_id}}</view>
				</view>
				<view class="iconfont icon-you1 right_box"></view>
			</view>
		</view>
		<!-- 导航跳转 -->
		<view class="two_box">
			<top-tab :tital='tab_list' @onClick="tabClick" :count="count"></top-tab>
		</view>
		<view class="last_box">
			<view class="title_box flex">
				<view class="title_list">可合作企业列表</view>
				<view class="title_more" @click="company_list()">查看更多</view>
			</view>
			<view class="companylist_box flex" v-for="(item,index) in list" :key='index' @tap="skip(item.company_id)">
				<image :src="item.logo" class="company-img" mode="aspectFill" v-if="item.logo"></image>
				<view class="nologo" v-if="!item.logo">{{item.company_name[0]}}</view>
				<view class="company_textbox">
					<view class="comtext_box">{{item.company_name}}</view>
					<text class="classify_box" v-for="(item,index) in item.tags" :key='index'>{{item}}</text>
				</view>
				<view class="iconfont icon-you1 rg_box"></view>
			</view>
		</view>
	</view>
</template>

<script>
	const {
		appLogin,
		httpGet,
		httpPost
	} = require("@/utils/common.js")
	export default {
		data() {
			return {
				school_name:'',
				school_id:'',
				teacher_id:'',
				page: 1,
				page_size: 20,
				list: [],
				logo:'',
				count:'',
				// 导航内容
				tab_list:[
					{
						tit:'班级管理',
						icon:'icon-banjiguanli',
						path:"class_control"
					},
					{
						tit:'企业管理',
						icon:'icon-qiye',
						path:"cooperate_company_list"
					},
					{
						tit:'实训圈',
						icon:'icon-shixi',
						path:"training_circle"
					},
					{
						tit:'消息通知',
						icon:'icon-a-xiaoxi',
						path:"message"
					},
					
				],
				url:'http://www.555edu.com/d/file/2018-04-03/1617f058d34fa3d52031266d389580e2.jpg'
				
			}
		},
		onLoad() {
			appLogin((user_info) => {
				console.log(user_info)
				this.getlist()
				this.getteacher_info()
				this.total_msg()
			})
		},
		onShow() {
			this.total_msg()
		},
		methods: {
			// 导航跳转
			tabClick(item){
				console.log(item)
				if(item.path)uni.navigateTo({
					url: item.path
				})
			},
			// 查看更多按钮
			company_list() {
				uni.navigateTo({
					url: 'company_list'
				})
			},
			onWsMessage(data){
				if(data.action == 'new_notice'){
					// 获取当前消息数
					this.total_msg();
				}
			},
			// 统计所以消息
			total_msg() {
				httpGet({
					url: '/api/school/notice_all_count',
					data: {
					
					}
				}).then(res => {
					console.log('统计所以消息')
					console.log(res)
					this.count = res.result.count
					
				})
			},
			// 获取企业列表
			getlist() {
				httpGet({
					url: '/api/company/list',
					data: {
						page: this.page,
						page_size: this.page_size
			
					}
				}).then(res => {
					console.log(res)
					this.list = res.result.list
				})
			},
			//获取老师信息
			getteacher_info(){
				httpGet({
					url:'/api/school/my_teacher',
					data:{
						
					}
				}).then((res) => {
					console.log(res)
					this.school_id = res.result.school_id
					this.teacher_id = res.result.teacher_id
					this.school_name = res.result.school_info.school_name
					this.logo = res.result.school_info.logo
					console.log(this.teacher_id)
					console.log(this.school_id)
				})
			},
			// 跳转到学校编辑
			skip_save(school_id){
				uni.navigateTo({
					url:'school_instroduce?school_id='+school_id
				})
			},
			
			//跳转企业详情并传递公司id参数
			skip(company_id) {
				uni.navigateTo({
					url: 'enterprise?company_id=' + company_id
				})
				console.log(company_id)
			}
		},
	}
</script>

<style>
	.one_box {
		height: 335rpx;
		width: 100%;
		padding-top: 35rpx;
		padding-left: 30rpx;
	}

	.img_box {
		width: 122rpx;
		height: 122rpx;
		border-radius: 180rpx;
		background-color: #FFFFFF;
		padding: 5rpx;
	}

	.img_school {
		width: 115rpx;
		height: 115rpx;
		border-radius: 180rpx;
	}
	.nologo_img {
		height: 115rpx;
		width: 115rpx;
		border-radius: 50%;
		background-color: #007AFF;
		text-align: center;
		line-height: 115rpx;
		font-size: 36rpx;
		color: #FFFFFF;
	}

	.text_box {
		margin-top: 20rpx;
		margin-left: 20rpx;
	}

	.schootext_box {
		color: #FFFFFF;
		font-size: 33rpx;
		margin-bottom: 25rpx;
	}

	.id_box {
		color: #b2c3fb;
		font-size: 25rpx;
	}

	.right_box {
		color: #FFFFFF;
		font-size: 25rpx;
		position: absolute;
		right: 30rpx;
		margin-top: 48rpx;
	}

	.two_box {
		width: 720rpx;
		height: 212rpx;
		background-color: #FFFFFF;
		margin: auto;
		margin-top: -120rpx;
		border-radius: 12rpx;
		padding-top: 55rpx;
	}

	.icon_textstyle {
		font-size: 25rpx;
		color: #666666;
	}

	.last_box {
		width: 718rpx;
		height: auto;
		background-color: #FFFFFF;
		margin: auto;
		margin-top: 28rpx;
		border-radius: 12rpx;
		padding-top: 42rpx;
	}

	.title_box {
		margin-left: 11rpx;
		width: 670rpx;
		height: 37rpx;
		margin: auto;
	}

	.title_list {
		color: #333333;
		font-size: 31rpx;
		
	}

	.title_more {
		color: #999999;
		font-size: 23rpx;
		margin-top: 8rpx;
		position: absolute;
		right: 43rpx;
	}

	.companylist_box {
		overflow-y: auto;
		width: 670rpx;
		border-bottom-color: #eeeeee;
		border-bottom-width: 1rpx;
		border-bottom-style: solid;
		margin: auto;
		padding-top: 40rpx;
		padding-bottom: 30rpx;
		height: 175rpx;
	}

	.company-img {
		width: 100rpx;
		height: 100rpx;
		border-radius:50%;
		margin-left: 10rpx;
	}
	.nologo{
		width: 100rpx;
		height: 100rpx;
		border-radius:50%;
		margin-left: 10rpx;
		background-color: #007AFF;
		text-align: center;
		line-height: 100rpx;
		color: #FFFFFF;
		font-size: 36rpx;
	}

	.company_textbox {
		margin-left: 20rpx;
		margin-top: 8rpx;
		
	}

	.comtext_box {
		font-size: 28rpx;
		color: #333333;
		margin-bottom: 10rpx;
	}

	.classify_box {
		font-size: 23rpx;
		color: #999999;
		margin-bottom: 6rpx;
		padding-right: 10rpx;
	}

	.company_num {
		font-size: 23rpx;
		color: #999999;
	}

	.rg_box {
		font-size: 26rpx;
		position: absolute;
		right: 43rpx;
		margin-top: 38rpx;
	}

	.red_text {
		width: 25rpx;
		height: 25rpx;
		border-radius: 180rpx;
		background-color: #ED1C24;
		color: #FFFFFF;
		position: absolute;
		line-height: 25rpx;
		top: -8rpx;
		right: 60rpx;
		text-align: center;
	}
</style>
